package com.marsyang.display
{
	import com.greensock.*;
	import com.greensock.easing.*;
	import com.marsyang.model.ModelLocator;
	
	import flash.display.Sprite;
	import flash.events.Event;
	
	public class Stage3D extends Sprite
	{
		public var planeObject:PlaneObject;
		public var model:ModelLocator = ModelLocator.getInstance();
		
		public function Stage3D()
		{
			createObject();
			addEventListener(Event.ENTER_FRAME, onRenderHandler);
		}
		private function createObject():void
		{
			planeObject = new PlaneObject();
			addChild(planeObject);
			planeObject.create();
			planeObject.setPlanesColor();
		}		
		private function onRenderHandler(event:Event = null):void
		{
			switch(model.renderType)
			{
				case "DEF":
					renderDef();
					break;
				case "IN":
					renderIn();
					break;
				case "IN_EFFECT":
					renderInEffect();
					break;
				case "OUT":
					renderOut();
					break;
				case "OUT_EFFECT":
					renderOutEffect();
					break;
				case "ROTA":
					renderRota();
					break;
				case "ON":
					renderOn();
					break;
				case "OFF":
					renderOff();
					break;
			}
			planeObject.onRender();
		}
		private function renderDef():void
		{
			model.renderType = "ON";
			planeObject.planesDefEffect();
			planeObject.setPlanesColor();
		}
		private function renderIn():void
		{
			model.renderType = "IN_EFFECT";
			planeObject.planesIn();
		}
		private function renderInEffect():void
		{
			//renderType = "ON";
		}
		private function renderOut():void
		{
			model.renderType = "OUT_EFFECT";
			planeObject.planesOut();
		}
		private function renderOutEffect():void
		{			
			model.renderType = "OFF";
		}
		private function renderOff():void
		{
			
		}
		public function renderRota():void
		{
			model.renderType = "OFF";
			planeObject.planesRota();
			
		}
		private function renderOn():void
		{
			planeObject.planesOnRender();
		}
	}
}